home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
wild
/
appunti
/
wildprefs.txt
< prev
next >
Wrap
Text File
|
1999-05-25
|
3KB
|
83 lines
WildPrefs.library design info.
This library must handle prefs loading, setting and saving.
So, also files in the ENV directory, and more.
Wild will call this in the AddWildApp func, if the WIAP_HandlePrefs
is specified: so, if you want your app to be handled by prefs, set it.
If you do, your tags will be replaced by the prefs defined tags, so
may be completely different from what you want: you can only suggest
the first config to be used by your app, but you cannot be sure of
what your app will use. That's obviously normal.
Your app will be identified by WildPrefs.library by your WIAP_BaseName:
so, give a short name, please...
funcs to implement:
- GetHandledList(): will give you the list of the Handled apps. So,
will list all the prefs files in the ENV dir, but will NOT OPEN
them! Just gives you the list, if you want to change something,
you must call LoadPrefs.
The list will contain a particular struct, containing all the
prefs things, but EMPTY apart the NAME: you will pass this to LoadPrefs.
- LoadPrefs(app,tags): will initialize the app struct (empty, with only the NAME)
with the values contained in the prefs file, or with default values if no
prefs file is found. Tags will contain the values used as default if no
value is found for some tags.
- FindNamedApp(name): will find an app in the Handled list, or will create one
if no match is be found. An empty prefs file will be created.
- SetPrefs(app,tags): will set some tags for this app, without applying them in any way.
- TestPrefs(app): will test the prefs on the app, but no filesave done.
- UsePrefs(app): will use the prefs on the app, and save them in ENV:.
- SavePrefs(app): will use the prefs on the app, and save them in ENV: and ENVARC:.
- FreePrefs(app): will free the prefs struct, close all files. The app struct
will be emptyed apart the name.
The path of prefs is:
ENV(ARC):Wild/
The filename for prefs is:
wild.prefs for the general wild optionsfile
_APPNAME.prefs for the specific app file.
The _ is used to avoid conflicts with wild.prefs and future ??.prefs files.
The Wild drawer is created everytime it is not present.
The GetHandledList() will look first in the ENV: assignement (if present)
and then in the ENVARC:.
The PrefsFileFormat:
Must only contain tags.
But some tags are strings !!
So, use the FileTag struct:
Structure FileTag
BYTE ft_Flags
BYTE ft_Len
LONG ft_Tag
LABEL ft_Data
A flag is the Pointer flag: does the data is included in the tag or is
pointed by the tag ?
Problem in SavePrefs: how know if a tag is a string tag or not !?
Simple:
- for standard defined WILD tags, use default NON-string tags and make
a file of the complex tags. (ENVARC:Wild/Complex.tags)
Structure ComplexTagsFile
WORD ct_Num
LABEL ct_Data (ARRAY OF LONG, NOT OF TAGS!!)
- for non-standard, define 2 wilduser tagbases: one for simple, one for complex.